package application.translators.impl;

import application.model.ChemicalCompositionsModel;
import application.model.PhaseCompositionModel;
import application.model.PhaseCompositionsModel;
import application.translators.Translator;
import mappings.PhaseComposition;

import java.util.List;

public class PhaseCompositionsTranslator implements Translator<List<PhaseComposition>, PhaseCompositionsModel>
{
    @Override
    public PhaseCompositionsModel translate(List<PhaseComposition> input)
    {
        PhaseCompositionsModel output = new PhaseCompositionsModel();

        for(PhaseComposition phaseComposition : input)
        {
            PhaseCompositionModel phaseCompositionModel = new PhaseCompositionModel();

            phaseCompositionModel.setMin(phaseComposition.getMin());
            phaseCompositionModel.setMax(phaseComposition.getMax());
            phaseCompositionModel.setPhase(phaseComposition.getPhases().getName());
            phaseCompositionModel.setPhotoUrl(phaseComposition.getPhotoComposition().getUrl());
            phaseCompositionModel.setPhotoDescription(phaseComposition.getPhotoComposition().getName());

            output.addPhaseCompositionModel(phaseCompositionModel);
        }

        return output;
    }
}
